package cn.tedu.cinema.cinemas.controller;

import cn.tedu.cinema.base.response.JsonResult;
import cn.tedu.cinema.cinemas.pojo.dto.CinemasQueryUser;
import cn.tedu.cinema.cinemas.pojo.dto.CinemasQuery;
import cn.tedu.cinema.cinemas.pojo.dto.CinemasSaveParam;
import cn.tedu.cinema.cinemas.pojo.vo.CinemasVO;
import cn.tedu.cinema.cinemas.service.CinemasService; 
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;


@Slf4j
@RestController
@RequestMapping("/v1/cinemas")
public class CinemasController {
    @Autowired
    CinemasService cinemasService;
    @PostMapping("save")
    public JsonResult saveCinemas(@RequestBody CinemasSaveParam cinemasSaveParam) {
        log.debug("开始处理【影院添加】，参数{} ", cinemasSaveParam);
        cinemasService.saveCinemas(cinemasSaveParam);
        return JsonResult.ok();
    }
    @PostMapping("delete/{id}")
    public JsonResult deleteCinemas(@PathVariable("id") Long id) {
        log.debug("开始处理【删除影院】，参数{} ", id);
        cinemasService.deleteCinemas(id);

        return JsonResult.ok();
    }

    @GetMapping("select")
    public JsonResult selectCinemas(CinemasQuery cinemasQuery ) {
        log.debug("开始处理【查询影院】,参数{}", cinemasQuery);
        List<CinemasVO> list = cinemasService.selectCinemas(cinemasQuery);
        return JsonResult.ok(list);

    }
    @GetMapping("selectCinemaByHallTypeAndCityAndPlanMovieId")
    public JsonResult selectCinemaByHallTypeAndCityAndPlanMovieId(CinemasQueryUser cinemasQueryUser) {
        log.debug("开始处理【查询影院】,参数{}", cinemasQueryUser);
        List<CinemasVO> list = cinemasService.selectCinemaByHallTypeAndCityAndPlanMovieId(cinemasQueryUser);
        return JsonResult.ok(list);
    }




}
